package com.heima.string.string;

public class StringDemo05 {
    public static void main(String[] args) {
        /**
         * 拼接字符串
         */
        int[] arr = {1, 2, 3};

        System.out.println(arrToString(arr));
    }
    public static String arrToString(int[] nums)
    {
        if(nums == null){
            return "";
        }
        if(nums.length == 0){
            return "[]";
        }
        String ret = "[";
        for (int i = 0; i < nums.length; i++) {
            if(i == 0) {
                ret += nums[i];
            }else{
                ret += ", "+nums[i];
            }
        }
        ret += "]";
        return ret;
    }
}
